<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>搜索员工</title>
<link rel = "stylesheet" href = "css/bootstrap.min.css">
<link rel = "stylesheet" href = "css/bootstrap-theme.min.css">
<script type="text/javascript" src = "js/jquery.min.js"></script>
<script type="text/javascript" src = "js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-default">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="index.jsp" style="color:orange;font-weight:bold">企业管理系统</a>
    </div>

    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li><a href="login.jsp" style="color:blue;font-size:16px">欢迎${requestScope.manager.admin}进入<span class="sr-only">(current)</span></a></li>
      </ul>
      
      <ul class="nav navbar-nav navbar-right">
        <li><a href="login.jsp">退出登录</a></li>
      </ul>
    </div>
  </div>
</nav>

<div class="row">
	<div class="col-md-2" style="margin-left:30px">
		<%@include file="menu.jsp"%>
	</div>
	
	<div class="col-md-9">
	  <div class="panel panel-default">
        <div class="panel-heading">员工查询</div>
          <div class="panel-body"> 
            <div class="row">
              <div class="col-md-12">
<form class="form-horizontal" method="POST" action="SearchUserServlet?curpage=1">
  <div class="form-group">          
    <label for="forname" class="col-md-1 control-label">姓名</label>
    <div class="col-md-3">
      <c:choose>
        <c:when test="${requestScope.name!=null }">
          <input type="text" class="form-control" id="forname" value="${requestScope.name}" name="name"  placeholder="请输入查询姓名">
        </c:when>
        <c:otherwise>
          <input type="text" class="form-control" id="forname"  name="name"  placeholder="请输入查询姓名">
        </c:otherwise>
      </c:choose>
    </div>
    <label for="forage" class="col-md-1 control-label">年龄</label>
    <div class="col-md-1">
      <c:choose>
        <c:when test="${requestScope.beginage!=null}">
          <input type="number" class="form-control" id="forage1" name="beginage" value="${requestScope.beginage}" placeholder="请输入查询的开始年龄">
        </c:when>
        <c:otherwise>
          <input type="number" class="form-control" id="forage1" name="beginage" placeholder="请输入查询的开始年龄">
        </c:otherwise>
      </c:choose>
    </div>
    <label for="forage" class="col-md-1 control-label">至</label>
    <div class="col-md-1">
      <c:choose>
        <c:when test="${requestScope.endage!=null}">
          <input type="number" class="form-control" id="forage2" name="endage" value="${requestScope.endage}" placeholder="请输入查询的结束年龄">
        </c:when>
        <c:otherwise>
          <input type="number" class="form-control" id="forage2" name="endage" placeholder="请输入查询的结束年龄">
        </c:otherwise>
      </c:choose>
    </div>
    <label for="forsex" class="col-md-1 control-label">性别</label>
      <div class="col-md-3">
        <c:choose>
          <c:when test="${requestScope.sex==0}">
            <label class="radio-inline">
              <input type="radio" name="sex" id="inlineRadio1" value="0" checked="checked">男
            </label>
            <label class="radio-inline">
              <input type="radio" name="sex" id="inlineRadio2" value="1"> 女
            </label>
            <label class="radio-inline">
              <input type="radio" name="sex" id="inlineRadio2" value="2">全部
            </label>
          </c:when>
          <c:when test="${requestScope.sex==1 }">
            <label class="radio-inline">
              <input type="radio" name="sex" id="inlineRadio1" value="0" >男
            </label>
            <label class="radio-inline">
              <input type="radio" name="sex" id="inlineRadio2" value="1" checked="checked"> 女
            </label>
            <label class="radio-inline">
              <input type="radio" name="sex" id="inlineRadio2" value="2">全部
            </label>
          </c:when>
          <c:otherwise>
            <label class="radio-inline">
              <input type="radio" name="sex" id="inlineRadio1" value="0" >男
            </label>
            <label class="radio-inline">
              <input type="radio" name="sex" id="inlineRadio2" value="1"> 女
            </label>
            <label class="radio-inline">
               <input type="radio" name="sex" id="inlineRadio2" value="2" checked="checked">全部
            </label>
          </c:otherwise>
        </c:choose>
      </div>
    </div>
  <div class="form-group">
    <label for="fordepart" class="col-md-1 control-label">部门</label>
    <div class="col-md-3">
      <select class="form-control" id="fordepart" name="did">
        <option value="-1">--请选择--</option>
        <c:forEach items="${requestScope.dlist }" var="item">
          <c:choose>
            <c:when test="${item.id==requestScope.did}">
              <option value="${item.id}" selected="selected">${item.dname}</option>
            </c:when>
            <c:otherwise>
              <option value="${item.id}">${item.dname}</option>
            </c:otherwise>
          </c:choose>
        </c:forEach>
      </select>
    </div>
    <div class="col-md-4" style="text-align: center">
      <input type="submit" class="btn btn-danger" value="--查询--">
    </div>
  </div>
</form>
          </div>
        </div>
<div class="row">
  <div class="col-md-12">
    <table class="table table-striped">
      <thead>
        <tr><th>序号</th><th>姓名</th><th>年龄</th><th>性别</th><th>部门</th></tr>
      </thead>
      <tbody>
      <c:forEach var="item" varStatus="t" items="${requestScope.list}">
        <tr>
          <td>${item.id}</td>
          <td>${item.ename }</td>
          <td>${item.age }</td>
          <td>${item.sex }</td>
          <td>${item.departname }</td>
        </tr>
      </c:forEach>
      </tbody>
    </table>
  </div>
</div>
<div class="row">
  <div class="col-md-12" style="text-align: center">
    <form action="" method="POST" id="f1">
      <input type="hidden" value="${requestScope.name}" name="name">
      <input type="hidden" value="${requestScope.beginage}" name="beginage">
      <input type="hidden" value="${requestScope.endage}" name="endage">
      <input type="hidden" value="${requestScope.sex}" name="sex">
      <input type="hidden" value="${requestScope.did}" name="did">
      <input type="hidden" value="${requestScope.curpage}" id="cp">
      <input type="hidden" value="${requestScope.counts}" id="fp">
      <nav style="text-align:center">
	    <ul class="pagination">
		  <c:if test="${requestScope.curpage>1 }">
		    <li><a href="QueryPageServlet?curpage=${requestScope.curpage-1}" aria-label="Previous">
			  <span aria-hidden="true">&laquo;</span>
			</a></li>
		  </c:if>
		  <c:forEach begin="1" step="1" end="${requestScope.counts }" var="item">
		    <c:if test="${requestScope.curpage==item }">
		      <li class="active"><a href="QueryPageServlet?curpage=${item }">${item}</a></li>
		    </c:if>
		    <c:if test="${requestScope.curpage!=item }">
		      <li><a href="QueryPageServlet?curpage=${item}">${item}</a></li>
		    </c:if>
		  </c:forEach>
		  <c:if test="${requestScope.curpage<requestScope.counts }">
			<li><a href="QueryPageServlet?curpage=${requestScope.curpage+1}" aria-label="Next">
			  <span aria-hidden="true">&raquo;</span>
			</a></li>
		  </c:if>
		</ul>
      </nav>
    </form>       
  </div>
</div>
      </div>
    </div>		
  </div>
</div>
</body>
</html>
